//
//  ViewController.m
//  UI_Homework_07_03
//
//  Created by 黄威 on 16/5/11.
//  Copyright © 2016年 黄威. All rights reserved.
//

#import "ViewController.h"
#import "UIimagepicker.h"
@interface ViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    
    [self create];
    
    
    
}

- (void)create{

    self.view.backgroundColor = [UIColor cyanColor];
    
    UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"6.jpg"]];
    
    image.frame = CGRectMake(0, 0, 200, 400);
    image.center = self.view.center;
    [self.view addSubview:image];

    self.navigationItem.title = @"相片选择器";
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(handle)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(handle2)];
   
    [image release];
    

}

- (void)handle{
   
    UIImagePickerController *pick = [[UIImagePickerController alloc] init];
    
    pick.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    pick.allowsEditing = YES;
    pick.allowsEditing = YES;
    pick.delegate = self;
    
    [self presentViewController:pick animated:YES completion:^{
        
    }];
    
}

- (void)handle2{

    UIImagePickerController *pick = [[UIImagePickerController alloc] init];
    
    pick.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    pick.allowsEditing = YES;
    pick.allowsEditing = YES;
    pick.delegate = self;
    
    [self presentViewController:pick animated:YES completion:^{
        
    }];

}


-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {
    [picker dismissViewControllerAnimated:YES completion:^{
        
    }];
    UIImageView *vie = [self.view viewWithTag:1000];
    vie.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    
    UIImageView *vie1 = [self.view viewWithTag:100];
    vie1.image = [info objectForKey:UIImagePickerControllerOriginalImage];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
